package org.gen.util;

import java.sql.Connection;
import java.sql.DatabaseMetaData;
import java.sql.DriverManager;

import org.gen.config.GenConfig;

/**
 *
 * @author 朱良才
 * @Email zhuliangcai@itcast.com
 * @Date 2017-10-16
 */
public class DBMetaUtil {
    private static DatabaseMetaData dbmd;

    static {
        try {
            //加载数据库驱动
            Class.forName(GenConfig.getDriverClassName());
            //获取连接
            Connection connection = DriverManager.getConnection(GenConfig.getJdbcurl(),
                    GenConfig.getUsername(), GenConfig.getPassword());
            //获取数据库源信息
            dbmd = connection.getMetaData();

        } catch (Exception e) {
            throw new RuntimeException("数据库连接异常");
        }

    }
    //获取数据库源信息
    public static DatabaseMetaData getMetaData() {
        return dbmd;
    }

}
